/*
 * @Author: ZephyrGao
 * @Date: 2023-11-17 10:38:26
 * @Description: 
 * Copyright (c) 2023 by ZephyrGao, All Rights Reserved. 
 */

import 'package:flutter/material.dart';

extension VanRowAlignExtension on MainAxisAlignment {
  WrapAlignment get wrapJustify => [
        WrapAlignment.start,
        WrapAlignment.end,
        WrapAlignment.center,
        WrapAlignment.spaceBetween,
        WrapAlignment.spaceAround,
        WrapAlignment.spaceEvenly,
      ][index];
}

extension VanRowCrossExtension on CrossAxisAlignment {
  WrapCrossAlignment get wrapAlign => [
        WrapCrossAlignment.start,
        WrapCrossAlignment.end,
        WrapCrossAlignment.center,
      ][index];
}

class VanRow extends StatelessWidget {
  const VanRow({
    super.key,
    this.children = const <Widget>[],
    this.gutter,
    this.justify = MainAxisAlignment.start,
    this.align = CrossAxisAlignment.start,
    this.wrap = true,
  });
  final List<Widget> children;
  final double? gutter;
  final MainAxisAlignment justify;
  final CrossAxisAlignment align;
  final bool wrap;

  @override
  Widget build(BuildContext context) {
    return wrap
        ? Wrap(
            crossAxisAlignment: align.wrapAlign,
            runAlignment: justify.wrapJustify,
            spacing: gutter ?? 0,
            runSpacing: gutter ?? 0,
            children: children,
          )
        : Row(
            mainAxisAlignment: justify,
            crossAxisAlignment: align,
            children: children,
          );
  }
}

class VanCol {}
